package com.financing.wap.service.impl;


import java.sql.SQLException;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.financing.wap.common.CommonConstantUtil.CommonStatus;
import com.financing.wap.dao.IDstMemberSendLogDao;
import com.financing.wap.dto.DstMemberSendLogDTO;
import com.financing.wap.service.IDstMemberSendLogService;
import com.financing.wap.util.DTOdateSetUtil;
import com.financing.wap.util.DateUtil;
import com.financing.wap.util.RandomUtils;
/**
 * dst_member_send_log  
 * 会员开通记录 业务访问层实现类
 * @author huqiyun
 *
 */
 
@Service("dstMemberSendLogService")
public class DstMemberSendLogServiceImpl implements IDstMemberSendLogService{

	@Autowired
	private IDstMemberSendLogDao dstMemberSendLogDao;

	@Override
	public int insert(DstMemberSendLogDTO dstMemberSendLog) throws SQLException {
		DTOdateSetUtil.setCreateInfo(dstMemberSendLog);
		DTOdateSetUtil.setUpdateInfo(dstMemberSendLog);
		dstMemberSendLog.setDeleteTag(CommonStatus.DELETE_TAG_NORMAL);
		//时间+8随机数
		if(StringUtils.isBlank(dstMemberSendLog.getSendOrderCode())){
			dstMemberSendLog.setSendOrderCode(DateUtil.getDate("yyyyMMddHHmmss")+RandomUtils.getRandomUtils(8));
		}
		return dstMemberSendLogDao.insert(dstMemberSendLog);
	}

	@Override
	public void update(DstMemberSendLogDTO dstMemberSendLog) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(dstMemberSendLog);
		dstMemberSendLogDao.update(dstMemberSendLog);
	}

	@Override
	public void updateForce(DstMemberSendLogDTO dstMemberSendLog) throws SQLException {
		DTOdateSetUtil.setUpdateInfo(dstMemberSendLog);
		dstMemberSendLogDao.updateForce(dstMemberSendLog);
	}

	@Override
	public void delete(Integer id) throws SQLException {
		dstMemberSendLogDao.delete(id);
	}
	
	@Override
	public List<DstMemberSendLogDTO> queryList(DstMemberSendLogDTO dstMemberSendLog) throws SQLException {
		return dstMemberSendLogDao.queryList(dstMemberSendLog);
	}

	@Override
	public int queryListCount(DstMemberSendLogDTO dstMemberSendLog) throws SQLException {
		return dstMemberSendLogDao.queryListCount(dstMemberSendLog);
	}

	@Override
	public DstMemberSendLogDTO loadById(Integer id) throws SQLException {
		return dstMemberSendLogDao.loadById(id);
	}
 	@Override
	public DstMemberSendLogDTO queryListGetFirst(DstMemberSendLogDTO dstMemberSendLog)
			throws SQLException {
		 List<DstMemberSendLogDTO> queryList = queryList(dstMemberSendLog);
		 if(queryList==null||queryList.size()==0){
			 return new DstMemberSendLogDTO();
		 }
		 return queryList.get(0);
	}
}
